package com.retail.product.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.List;

/**
 * 商品添加请求DTO
 *
 * @author retail
 * @since 2024-09-25
 */
@Data
@Schema(description = "商品添加请求DTO")
public class ProductAddDTO {

    @Schema(description = "商品名称", example = "iPhone 15 Pro")
    @NotBlank(message = "商品名称不能为空")
    @Size(max = 200, message = "商品名称长度不能超过200个字符")
    private String name;

    @Schema(description = "商品描述", example = "Apple iPhone 15 Pro 256GB 蓝色钛金属")
    private String description;

    @Schema(description = "商品分类ID", example = "1")
    @NotNull(message = "商品分类ID不能为空")
    private Long categoryId;

    @Schema(description = "品牌", example = "Apple")
    private String brand;

    @Schema(description = "型号", example = "iPhone 15 Pro")
    private String model;

    @Schema(description = "价格", example = "7999.00")
    @NotNull(message = "价格不能为空")
    @PositiveOrZero(message = "价格必须大于等于0")
    private BigDecimal price;

    @Schema(description = "成本价", example = "6000.00")
    @PositiveOrZero(message = "成本价必须大于等于0")
    private BigDecimal costPrice;

    @Schema(description = "库存数量", example = "100")
    @PositiveOrZero(message = "库存数量必须大于等于0")
    private Integer stockQuantity;

    @Schema(description = "低库存阈值", example = "10")
    @PositiveOrZero(message = "低库存阈值必须大于等于0")
    private Integer lowStockThreshold;

    @Schema(description = "重量(kg)", example = "0.187")
    @PositiveOrZero(message = "重量必须大于等于0")
    private BigDecimal weight;

    @Schema(description = "体积(m³)", example = "0.0001")
    @PositiveOrZero(message = "体积必须大于等于0")
    private BigDecimal volume;

    @Schema(description = "商品图片列表")
    @Valid
    private List<ProductImageDTO> images;

    @Data
    @Schema(description = "商品图片DTO")
    public static class ProductImageDTO {
        @Schema(description = "图片URL", example = "http://example.com/image1.jpg")
        @NotBlank(message = "图片URL不能为空")
        private String imageUrl;

        @Schema(description = "图片类型：1-主图，2-详情图", example = "1")
        private Integer imageType;

        @Schema(description = "排序", example = "0")
        private Integer sortOrder;
    }
}